<?php 
class Menu
{
	function getMenu($parent=0, $link_type=-1)
	{
		$wheread = '';
		if($parent > 0)
		{ $wheread  = ' AND parent_id='.$parent; }
		if($link_type > 0)
		{ $wheread .= ' AND link_type='.$link_type; }
		
		$i=0;
		$select = 'SELECT * FROM '.DB_PERFIX.'sitemap_pages WHERE site_id='.SITE_ID.' AND link_type=6 AND active=1 '.$wheread.' ORDER BY menu_order, title ASC;';
		$result = mysql_query($select);
		if($result)
		{
			$i = 0;
			while($row = mysql_fetch_array($result))
			{
				foreach(array_keys($row) as $key)
				{ 
					$item[$i][$key] = $row[$key]; 
					if($_REQUEST['m'] == $row['id'])
					{ $item[$i]['selected'] = 1; }
					else
					if($_REQUEST['m'] == $row['id'])
					{ $item[$i]['selected'] = 0; }
				}
				$i++;
			}
			return $item;
		}
		
	}
	
	function getMenuParentID($id=0)
	{
		if($id > 0)
		{
			$result = mysql_query('SELECT parent_id FROM '.DB_PERFIX.'sitemap_pages WHERE id='.$id.';');
			if($result)
			{
				while($row = mysql_fetch_array($result))
				{ $item = $row['parent_id']; }
				return $item;
			}
		}
	}
}

?>